package com.ljx.NoteBody.service.impl;

import com.ljx.NoteBody.dto.LabelDto;
import com.ljx.NoteBody.dto.NoteDto;
import com.ljx.NoteBody.entity.Label;
import com.ljx.NoteBody.mapper.LabelMapper;
import com.ljx.NoteBody.service.LabelService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class LabelServiceImpl implements LabelService {

    @Autowired
    LabelMapper labelMapper;

    @Override
    public List<LabelDto> yun() {
        List<LabelDto> labelDtoList = new ArrayList<>();
        for(Label label: labelMapper.orderLabel()){
            LabelDto labelDto = new LabelDto();
            BeanUtils.copyProperties(label, labelDto);
            labelDto.setNum(labelMapper.queryYunCount(label.getId()));
            labelDtoList.add(labelDto);
        }
        return labelDtoList;
    }
}
